﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace WindowsFormsApplication1.wtyczki
{
    public static class addPictures
    {
        public static Bitmap addPics(Bitmap bmf, Bitmap bms)
        {
            Bitmap bmTmp = new Bitmap(bmf);
            if (bmf == null && bms == null)
                return null;
            else if (bmf == null)
                return bms;
            else if (bms == null)
                return bmf;
            int r, g, b;
            for (int x = 0; x < bmf.Width && x<bms.Width; x++)
                for (int y = 0; y < bmf.Height && y<bms.Width; y++)
                {
                    r = bmTmp.GetPixel(x, y).R + bms.GetPixel(x, y).R;
                    g = bmTmp.GetPixel(x, y).G + bms.GetPixel(x, y).G;
                    b = bmTmp.GetPixel(x, y).B + bms.GetPixel(x, y).B;
                    bmTmp.SetPixel(x, y, Color.FromArgb(r / 2, g / 2, b / 2));
                }
            return bmTmp;
        }
    }
}
